home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 December / macformat-057.iso / mac / Demos / Lineker's Real Football Demo / DATA / scrollmenu.dir / 00001.ls next >
Encoding:
Text File  |  1997-08-03  |  6.7 KB  |  272 lines

  1. global current, hoff, hpos, hcol, msprite, fsprite, hspace, datecast, spriteorder, keydates, lasthl, cdvar, bigskip, currentmin, currentmax
  2.  
  3. on startMovie
  4.   setupdatevars()
  5.   setupdummydates()
  6. end
  7.  
  8. on setupmenu
  9.   set fsprite to 9
  10.   set bigskip to 28
  11.   set datecast to the number of member "datecast"
  12.   set spriteorder to [0, 1, 2, 3, 4, 5]
  13.   set current to 1
  14.   set currentmin to 1
  15.   set currentmax to 2557
  16.   repeat with j = 1 to 6
  17.     puppetSprite(fsprite + j, 1)
  18.     set the text of cast (datecast + (j - 1)) to finddate(mygetat(keydates, current + (j - 3)))
  19.     set the foreColor of member (datecast + (j - 1)) to 0
  20.   end repeat
  21.   set lasthl to datecast + 2
  22.   set the foreColor of member lasthl to 5
  23.   set hoff to 0
  24.   set hspace to 128
  25.   updateStage()
  26. end
  27.  
  28. on redisplaydates
  29.   if cdvar then
  30.     repeat with j = 1 to 6
  31.       set the text of cast (datecast + getAt(spriteorder, j)) to finddate(mygetat(keydates, current + (bigskip * (cdvar * (j - 3)))))
  32.     end repeat
  33.   else
  34.     repeat with j = 1 to 6
  35.       set the text of cast (datecast + getAt(spriteorder, j)) to finddate(mygetat(keydates, current + (j - 3)))
  36.     end repeat
  37.   end if
  38.   updateStage()
  39. end
  40.  
  41. on scrolldates
  42.   if lasthl <> 0 then
  43.     set the foreColor of member lasthl to 0
  44.     set lasthl to 0
  45.   end if
  46.   set STEP to 20
  47.   set range to 100
  48.   set baseH to the mouseH
  49.   repeat while the stillDown
  50.     set TMPH to the mouseH
  51.     set TMPH to TMPH - baseH
  52.     if TMPH <> 0 then
  53.       set X to -TMPH / 5
  54.       if X > 48 then
  55.         set X to 48
  56.       else
  57.         if X < -48 then
  58.           set X to -48
  59.         end if
  60.       end if
  61.     end if
  62.     if moveposs(X) then
  63.       displaydates(X)
  64.     end if
  65.   end repeat
  66.   updateStage()
  67. end
  68.  
  69. on mywait val
  70.   global lasttime
  71.   repeat while the ticks < (lasttime + val)
  72.   end repeat
  73.   set lasttime to the ticks
  74. end
  75.  
  76. on findclosest
  77.   set sofar to 1000
  78.   repeat with j = 1 to 6
  79.     set dist to abs(320 - (the locH of sprite (10 + (j - 1)) + 64))
  80.     if dist <= sofar then
  81.       set sofar to dist
  82.       set cnum to j - 1
  83.     end if
  84.   end repeat
  85.   return cnum
  86. end
  87.  
  88. on lockondates
  89.   set closest to findclosest()
  90.   set p1 to the locH of sprite (10 + closest) + 64
  91.   if p1 > 320 then
  92.     set tdist to p1 - 320
  93.     set tmpdist to tdist
  94.     repeat while tmpdist <> 0
  95.       set scrollval to tmpdist / 5
  96.       if scrollval < 1 then
  97.         set scrollval to 1
  98.       end if
  99.       displaydates(-scrollval)
  100.       set tmpdist to tmpdist - scrollval
  101.     end repeat
  102.   else
  103.     if p1 < 320 then
  104.       set tdist to 320 - p1
  105.       set tmpdist to tdist
  106.       repeat while tmpdist <> 0
  107.         set scrollval to tmpdist / 5
  108.         if scrollval < 1 then
  109.           set scrollval to 1
  110.         end if
  111.         displaydates(scrollval)
  112.         set tmpdist to tmpdist - scrollval
  113.       end repeat
  114.     else
  115.       autoclick()
  116.     end if
  117.   end if
  118.   set closest to findclosest()
  119.   set lasthl to datecast + closest
  120.   set the foreColor of member lasthl to 5
  121.   updateStage()
  122. end
  123.  
  124. on autoclick
  125.   set tclickpt to the clickLoc
  126.   set tclick to getAt(tclickpt, 1)
  127.   if tclick > 512 then
  128.     set scdir to -2
  129.   else
  130.     if tclick > 384 then
  131.       set scdir to -1
  132.     else
  133.       if tclick < 128 then
  134.         set scdir to 2
  135.       else
  136.         if tclick < 256 then
  137.           set scdir to 1
  138.         end if
  139.       end if
  140.     end if
  141.   end if
  142.   if movepossauto(scdir) then
  143.     set tdist to 128
  144.     set tmpdist to tdist
  145.     repeat while tmpdist <> 0
  146.       set scrollval to tmpdist / 5
  147.       if scrollval < 1 then
  148.         set scrollval to 1
  149.       end if
  150.       displaydates(scrollval * scdir)
  151.       set tmpdist to tmpdist - scrollval
  152.     end repeat
  153.     set closest to findclosest()
  154.     set lasthl to datecast + closest
  155.     set the foreColor of member lasthl to 5
  156.     updateStage()
  157.   end if
  158. end
  159.  
  160. on movepossauto dir
  161.   if cdvar then
  162.     if dir > 0 then
  163.       if (current - bigskip - ((dir - 1) * bigskip)) >= currentmin then
  164.         return 1
  165.       else
  166.         return 0
  167.       end if
  168.     else
  169.       if dir < 0 then
  170.         if (current + bigskip + ((abs(dir) - 1) * bigskip)) <= currentmax then
  171.           return 1
  172.         else
  173.           return 0
  174.         end if
  175.       end if
  176.     end if
  177.   else
  178.     if (((current - (dir - 1)) > currentmin) and (dir > 0)) or (((current + (abs(dir) - 1)) < currentmax) and (dir < 0)) then
  179.       return 1
  180.     else
  181.       return 0
  182.     end if
  183.   end if
  184. end
  185.  
  186. on moveposs dir
  187.   if cdvar then
  188.     if dir > 0 then
  189.       if (current - bigskip) > currentmin then
  190.         return 1
  191.       else
  192.         return 0
  193.       end if
  194.     else
  195.       if dir < 0 then
  196.         if (current + bigskip) < currentmax then
  197.           return 1
  198.         else
  199.           return 0
  200.         end if
  201.       end if
  202.     end if
  203.   else
  204.     if ((current > currentmin) and (dir > 0)) or ((current < currentmax) and (dir < 0)) then
  205.       return 1
  206.     else
  207.       return 0
  208.     end if
  209.   end if
  210. end
  211.  
  212. on displaydates factor
  213.   if factor < 0 then
  214.     if the locH of sprite (fsprite + 1 + getAt(spriteorder, 1)) <= -126 then
  215.       set the locH of sprite (fsprite + 1 + getAt(spriteorder, 1)) to the locH of sprite (fsprite + 1 + getAt(spriteorder, 1)) + 640 + 128
  216.       switchorder(1)
  217.     end if
  218.   else
  219.     if factor > 0 then
  220.       if the locH of sprite (fsprite + 1 + getAt(spriteorder, 6)) >= 640 then
  221.         set the locH of sprite (fsprite + 1 + getAt(spriteorder, 6)) to the locH of sprite (fsprite + 1 + getAt(spriteorder, 6)) - 640 - 128
  222.         switchorder(0)
  223.       end if
  224.     end if
  225.   end if
  226.   repeat with j = 1 to 6
  227.     set spriteloch to the locH of sprite (fsprite + 1 + getAt(spriteorder, j))
  228.     set spriteloch to spriteloch + factor
  229.     set the locH of sprite (fsprite + 1 + getAt(spriteorder, j)) to spriteloch
  230.   end repeat
  231.   mywait(1)
  232.   updateStage()
  233. end
  234.  
  235. on switchorder right
  236.   if right then
  237.     set tmp to getAt(spriteorder, 1)
  238.     repeat with j = 1 to 5
  239.       setAt(spriteorder, j, getAt(spriteorder, j + 1))
  240.     end repeat
  241.     setAt(spriteorder, 6, tmp)
  242.     if cdvar then
  243.       set current to current + bigskip
  244.       set the text of cast (datecast + getAt(spriteorder, 6)) to finddate(mygetat(keydates, current + (3 * bigskip)))
  245.     else
  246.       set current to current + 1
  247.       set the text of cast (datecast + getAt(spriteorder, 6)) to finddate(mygetat(keydates, current + 3))
  248.     end if
  249.   else
  250.     set tmp to getAt(spriteorder, 6)
  251.     repeat with j = 6 down to 2
  252.       setAt(spriteorder, j, getAt(spriteorder, j - 1))
  253.     end repeat
  254.     setAt(spriteorder, 1, tmp)
  255.     if cdvar then
  256.       set current to current - bigskip
  257.       set the text of cast (datecast + getAt(spriteorder, 1)) to finddate(mygetat(keydates, current - (2 * bigskip)))
  258.     else
  259.       set current to current - 1
  260.       set the text of cast (datecast + getAt(spriteorder, 1)) to finddate(mygetat(keydates, current - 2))
  261.     end if
  262.   end if
  263. end
  264.  
  265. on mygetat var, pos
  266.   if (pos < currentmin) or (pos > currentmax) then
  267.     return 0
  268.   else
  269.     return getAt(var, pos)
  270.   end if
  271. end
  272.